#ifndef CONFIGURE_HH
#define CONFIGURE_HH

//Port Define

#define SCK PB0
#define SDA PB1
#define RST PB2
#define CD PB3
#define CS PB4
#define LCD_PORT PORTB

#define SET_SCK_0 LCD_PORT &= ~(1 << SCK) //SCK=0;
#define SET_SCK_1 LCD_PORT |= (1 << SCK)  //SCK=1

#define SET_SDA_0 LCD_PORT &= ~(1 << SDA) //SDA=0;
#define SET_SDA_1 LCD_PORT |= (1 << SDA)  //SDA=1

#define SET_RST_0 LCD_PORT &= ~(1 << RST) //RST=0;
#define SET_RST_1 LCD_PORT |= (1 << RST)  //RST=1

#define SET_CD_0 LCD_PORT &= ~(1 << CD) //CD=0;
#define SET_CD_1 LCD_PORT |= (1 << CD)  //CD=1

#define SET_CS_0 LCD_PORT &= ~(1 << CS) //CS=0;
#define SET_CS_1 LCD_PORT |= (1 << CS)  //CS=1



// Display  Size

#define LCD_WIDTH 192
#define LCD_HEIGHT 64

#define BUF_WIDTH 64
#define BUF_HEIGHT 64

// Display Pixel colours   definition
// (1): white on blue,  FG = white BG = blue
// ERM19264SBS-4 LCD Display White on Blue
// (2): black on white, FG = black BG = white
// ERM19264FS-4 LCD Display Black on White
// (3):white on black,  FG = white, BG = black
// ERM19264DNS-4LCD Display White on Black
#define FOREGROUND  0
#define BACKGROUND 1
#define INVERSE 2


// UC1909 Read registers
#define UC1609_GET_STATUS 0x01 // Not used v1.0

// UC1909 Write registers
#define UC1609_SYSTEM_RESET 0xE2 // Not used v1.0

#define UC1609_POWER_CONTROL 0x2F 
#define UC1609_PC_SET 0x06 // PC[2:0] 110 Internal V LCD (7x charge pump) + 10b: 1.4mA

#define UC1609_ADDRESS_CONTROL 0x88 // set RAM address control
#define UC1609_ADDRESS_SET 0x02 // Set AC [2:0] Program registers  for RAM address control.

#define UC1609_SET_PAGEADD 0xB0 // Page address Set PA[3:0]
#define UC1609_SET_COLADD_LSB 0x00 // Column Address Set CA [3:0]
#define UC1609_SET_COLADD_MSB 0x10 // Column Address Set CA [7:4]

#define UC1609_TEMP_COMP_REG 0x27 // Temperature Compensation Register
#define UC1609_TEMP_COMP_SET 0x00 // TC[1:0] = 00b= -0.00%/ C

#define UC1609_FRAMERATE_REG 0xA0 // Frame rate
#define UC1609_FRAMERATE_SET 0x01  // Set Frame Rate LC [4:3] 01b: 95 fps

#define UC1609_BIAS_RATIO 0xE8 // Bias Ratio. The ratio between V-LCD and V-D .
#define UC1609_BIAS_RATIO_SET 0x03 //  Set BR[1:0] = 11 (set to 9 default)

#define UC1609_GN_PM 0x81 // Set V BIAS Potentiometer to fine tune V-D and V-LCD  (double-byte command)
#define UC1609_DEFAULT_GN_PM 0x49 // default only used if user does not specify Vbias

#define UC1609_LCD_CONTROL 0xC0 // Rotate map control
#define UC1609_DISPLAY_ON 0xAE // enables display
#define UC1609_ALL_PIXEL_ON 0xA4 // sets on all Pixels on
#define UC1609_INVERSE_DISPLAY 0xA6 // inverts display
#define UC1609_SCROLL 0x40 // scrolls , Set the scroll line number. 0-64

// Rotate
#define UC1609_ROTATION_FLIP_TWO 0x06
#define UC1609_ROTATION_NORMAL 0x04
#define UC1609_ROTATION_FLIP_ONE 0x02
#define UC1609_ROTATION_FLIP_THREE 0x00

// Delays
#define UC1609_RESET_DELAY 50 // mS delay . datasheet says 3uS
#define UC1609_RESET_DELAY2   0 // mS delay . DataSheet says 5mS
#define UC1609_INIT_DELAY 100   //  mS delay
#define UC1609_INIT_DELAY2 3 // mS delay . DataSheet says 3mS

#endif
